package com.yy.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener;
import org.springframework.stereotype.Component;

@Component
public class MyCancelListener implements ChannelAwareMessageListener {

    @RabbitListener(queues = "q.dlx", ackMode = "MANUAL")
    public void onMessage(Message message, Channel channel) throws Exception {
        String orderId = new String(message.getBody());
        System.out.println("取消订单：" + orderId);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }
}
